package com.geovis.emergency.spd.controller.pc;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.geovis.common.core.api.Result;
import com.geovis.common.core.controller.BaseController;
import com.geovis.emergency.spd.biz.pc.service.IPcDrillPlanResponseService;
import com.geovis.emergency.spd.entity.pc.entity.PcDrillPlanResponse;
import com.geovis.emergency.spd.entity.pc.pojo.dto.PcDrillPlanResponseDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 应急预案指挥模块 -  演练响应预案 前端控制器
 * </p>
*
* @author Lonsho
* @since 2022-06-17
*/
@RestController
@RequestMapping("/pc/drillPlanResponse")
@RequiredArgsConstructor
@Api(value = "应急预案指挥模块 -  演练响应预案接口", tags = "应急预案指挥模块 -  演练响应预案接口")
@Slf4j
@Validated
public class PcDrillPlanResponseController extends BaseController<IPcDrillPlanResponseService> {

    @ApiOperation(value = "根据演练id 和灾害事件id 获取响应预案列表", notes = "根据演练id 和灾害事件id 获取响应预案列表")
    @PostMapping("/getList")
    public Result<List<PcDrillPlanResponse>> getList(@RequestBody @Validated PcDrillPlanResponseDTO pcDrillPlanResponseDTO) {
        List<PcDrillPlanResponse> r=null;
        if(ObjectUtil.isNotEmpty(pcDrillPlanResponseDTO.getDrillId())
                &ObjectUtil.isNotEmpty(pcDrillPlanResponseDTO.getEventId())) {
            r = baseService.list(Wrappers.lambdaQuery(PcDrillPlanResponse.class)
                    .eq(PcDrillPlanResponse::getPcDrillId, pcDrillPlanResponseDTO.getDrillId())
                    .eq(PcDrillPlanResponse::getPcDrillDisasterEventId, pcDrillPlanResponseDTO.getEventId()));
        }
        return Result.ok(r);
    }
}
